package Exercise;

import java.util.Arrays;
import java.util.Comparator;

public class CalculateExe1 {
    public static void main(String[] args) {

        GirlFriend gf1=new GirlFriend("xiaofeifei",18,1.65);
        GirlFriend gf2=new GirlFriend("xiaojunjun",19,1.63);
        GirlFriend gf3=new GirlFriend("xiaojiajia",19,1.67);
        GirlFriend gf4=new GirlFriend("aiaojiajia",19,1.67);

        GirlFriend []arr={gf1,gf2,gf3,gf4};
        Arrays.sort(arr, (o1, o2)-> {
                double tmp= o1.getAge()- o2.getAge();
                tmp = tmp == 0 ? o1.getHeight() - o2.getHeight() : tmp;
                tmp = tmp == 0 ? o1.getName().compareTo(o2.getName()): tmp;
                if(tmp>0){
                    return 1;
                }else if(tmp<0){
                    return -1;
                }else{
                    return 0;
                }
            }
        );

        System.out.println(Arrays.toString(arr));

    }


}
